#============================================================
#    Node Pool
#============================================================
# - datetime: 2022-10-06 11:04:08
#============================================================
class_name NodePool



static func get_instance(class_) -> Node:
	var list : Array
	if Engine.get_main_loop().has_meta(class_):
		list = Engine.get_main_loop().get_meta(class_) as Array
	else:
		list = []
		Engine.get_main_loop().set_meta(class_, list)
	
	if list.size() > 0:
		return list.pop_back() as Node
	else:
		var node = class_.new()
		if node is Node:
			node.tree_exited.connect(func(): list.push_back(node) )
			return node
		else:
			return null


